﻿<Window x:Class="WPFColors.MainWindow"
        Title="WPFColors"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Height="350" Width="525">

    <ListBox 
        Padding="0"
        Margin="0"
        Grid.Column="0" 
        ItemsSource="{Binding Path=.}"
        SnapsToDevicePixels="True"
        ScrollViewer.HorizontalScrollBarVisibility="Disabled"
        >
            
        <ListBox.ItemsPanel>
            <ItemsPanelTemplate>
                <!--<WrapPanel  />-->
                <UniformGrid Columns="4" />
            </ItemsPanelTemplate>
        </ListBox.ItemsPanel>

        <ListBox.ItemContainerStyle>
            <Style TargetType="{x:Type ListBoxItem}">
                <Setter Property="HorizontalContentAlignment" Value="Stretch" />
                <Setter Property="VerticalContentAlignment" Value="Stretch" />
                <Setter Property="Padding" Value="0" />
            </Style>
        </ListBox.ItemContainerStyle>
        
        <ListBox.ItemTemplate>
            <DataTemplate>

                <!--
                <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition  MinWidth="10" Width="*" SharedSizeGroup="SingleWidthColumn"></ColumnDefinition>
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition  MinHeight="10" Height="*"  SharedSizeGroup="SingleHeightColumn"></RowDefinition>
                </Grid.RowDefinitions>
                </Grid>
                -->

                <Border 
                    BorderBrush="Black" 
                    BorderThickness="1" 
                    Background="{Binding Path=Hex}" >

                    <TextBlock
                        VerticalAlignment="Center"
                        HorizontalAlignment="Center"
                        TextAlignment="Center"
                        >
                                
                        <Run Text="{Binding Path=Name}" />
                        <LineBreak />
                        <Run Text="{Binding Path=Hex}" />

                    </TextBlock>

                </Border>
                
            </DataTemplate>
        </ListBox.ItemTemplate>
            
    </ListBox>
        
</Window>
